clipboard: Make a bunch of functions vfuncs
authorBenjamin Otte <otte@redhat.com>
Tue, 20 Aug 2013 12:44:14 +0000 (14:44 +0200)
committerBenjamin Otte <otte@redhat.com>
Tue, 20 Aug 2013 14:34:29 +0000 (16:34 +0200)
gtk/gtkclipboard.c
gtk/gtkclipboardprivate.h

index 6ef8d7dcb22a7835cb9ccac8a265a263cef8cf66..24073523cfa643977900f1c9e7c49f30cabf1cfb 100644 (file)
@@ -163,6 +163,23 @@ static void gtk_clipboard_class_init   (GtkClipboardClass   *class);
 static void gtk_clipboard_finalize     (GObject             *object);
 static void gtk_clipboard_owner_change (GtkClipboard        *clipboard,
                                        GdkEventOwnerChange *event);
+static gboolean gtk_clipboard_set_contents      (GtkClipboard                   *clipboard,
+                                                 const GtkTargetEntry           *targets,
+                                                 guint                           n_targets,
+                                                 GtkClipboardGetFunc             get_func,
+                                                 GtkClipboardClearFunc           clear_func,
+                                                 gpointer                        user_data,
+                                                 gboolean                        have_owner);
+static void gtk_clipboard_real_clear            (GtkClipboard                   *clipboard);
+static void gtk_clipboard_real_request_contents (GtkClipboard                   *clipboard,
+                                                 GdkAtom                         target,
+                                                 GtkClipboardReceivedFunc        callback,
+                                                 gpointer                        user_data);
+static void gtk_clipboard_real_set_can_store    (GtkClipboard                   *clipboard,
+                                                 const GtkTargetEntry           *targets,
+                                                 gint                            n_targets);
+static void gtk_clipboard_real_store            (GtkClipboard                   *clipboard);
+
 
 static void          clipboard_unset      (GtkClipboard     *clipboard);
 static void          selection_received   (GtkWidget        *widget,
@@ -204,6 +221,11 @@ gtk_clipboard_class_init (GtkClipboardClass *class)
 
   gobject_class->finalize = gtk_clipboard_finalize;
 
+  class->set_contents = gtk_clipboard_set_contents;
+  class->clear = gtk_clipboard_real_clear;
+  class->request_contents = gtk_clipboard_real_request_contents;
+  class->set_can_store = gtk_clipboard_real_set_can_store;
+  class->store = gtk_clipboard_real_store;
   class->owner_change = gtk_clipboard_owner_change;
 
   /**
@@ -629,9 +651,13 @@ gtk_clipboard_set_with_data (GtkClipboard          *clipboard,
   g_return_val_if_fail (targets != NULL, FALSE);
   g_return_val_if_fail (get_func != NULL, FALSE);
 
-  return gtk_clipboard_set_contents (clipboard, targets, n_targets,
-                                    get_func, clear_func, user_data,
-                                    FALSE);
+  return GTK_CLIPBOARD_GET_CLASS (clipboard)->set_contents (clipboard,
+                                                            targets,
+                                                            n_targets,
+                                                           get_func,
+                                                            clear_func,
+                                                            user_data,
+                                                           FALSE);
 }
 
 /**
@@ -672,9 +698,13 @@ gtk_clipboard_set_with_owner (GtkClipboard          *clipboard,
   g_return_val_if_fail (get_func != NULL, FALSE);
   g_return_val_if_fail (G_IS_OBJECT (owner), FALSE);
 
-  return gtk_clipboard_set_contents (clipboard, targets, n_targets,
-                                    get_func, clear_func, owner,
-                                    TRUE);
+  return GTK_CLIPBOARD_GET_CLASS (clipboard)->set_contents (clipboard,
+                                                            targets,
+                                                            n_targets,
+                                                           get_func,
+                                                            clear_func,
+                                                            owner,
+                                                           TRUE);
 }
 
 /**
@@ -753,6 +783,12 @@ gtk_clipboard_clear (GtkClipboard *clipboard)
 {
   g_return_if_fail (clipboard != NULL);
 
+  GTK_CLIPBOARD_GET_CLASS (clipboard)->clear (clipboard);
+}
+
+static void
+gtk_clipboard_real_clear (GtkClipboard *clipboard)
+{
   if (clipboard->have_selection)
     gtk_selection_owner_set_for_display (clipboard->display, 
                                         NULL,
@@ -929,15 +965,27 @@ gtk_clipboard_request_contents (GtkClipboard            *clipboard,
                                GdkAtom                  target,
                                GtkClipboardReceivedFunc callback,
                                gpointer                 user_data)
+{
+  g_return_if_fail (clipboard != NULL);
+  g_return_if_fail (target != GDK_NONE);
+  g_return_if_fail (callback != NULL);
+
+  GTK_CLIPBOARD_GET_CLASS (clipboard)->request_contents (clipboard,
+                                                         target,
+                                                         callback,
+                                                         user_data);
+}
+
+static void 
+gtk_clipboard_real_request_contents (GtkClipboard            *clipboard,
+                                     GdkAtom                  target,
+                                     GtkClipboardReceivedFunc callback,
+                                     gpointer                 user_data)
 {
   RequestContentsInfo *info;
   GtkWidget *widget;
   GtkWidget *clipboard_widget;
 
-  g_return_if_fail (clipboard != NULL);
-  g_return_if_fail (target != GDK_NONE);
-  g_return_if_fail (callback != NULL);
-  
   clipboard_widget = get_clipboard_widget (clipboard->display);
 
   if (get_request_contents_info (clipboard_widget))
@@ -1985,6 +2033,19 @@ void
 gtk_clipboard_set_can_store (GtkClipboard         *clipboard,
                             const GtkTargetEntry *targets,
                             gint                  n_targets)
+{
+  g_return_if_fail (GTK_IS_CLIPBOARD (clipboard));
+  g_return_if_fail (n_targets >= 0);
+
+  GTK_CLIPBOARD_GET_CLASS (clipboard)->set_can_store (clipboard,
+                                                      targets,
+                                                      n_targets);
+}
+
+static void
+gtk_clipboard_real_set_can_store (GtkClipboard         *clipboard,
+                                  const GtkTargetEntry *targets,
+                                  gint                  n_targets)
 {
   GtkWidget *clipboard_widget;
   int i;
@@ -1992,9 +2053,6 @@ gtk_clipboard_set_can_store (GtkClipboard         *clipboard,
     { "SAVE_TARGETS", 0, TARGET_SAVE_TARGETS }
   };
   
-  g_return_if_fail (GTK_IS_CLIPBOARD (clipboard));
-  g_return_if_fail (n_targets >= 0);
-
   if (clipboard->selection != GDK_SELECTION_CLIPBOARD)
     return;
   
@@ -2047,10 +2105,16 @@ gtk_clipboard_selection_notify (GtkWidget         *widget,
 void
 gtk_clipboard_store (GtkClipboard *clipboard)
 {
-  GtkWidget *clipboard_widget;
-
   g_return_if_fail (GTK_IS_CLIPBOARD (clipboard));
 
+  GTK_CLIPBOARD_GET_CLASS (clipboard)->store (clipboard);
+}
+
+static void
+gtk_clipboard_real_store (GtkClipboard *clipboard)
+{
+  GtkWidget *clipboard_widget;
+
   if (clipboard->n_storable_targets < 0)
     return;
   
index 788bf75950bc9d9c83834f589bd4b006f1d23044..48e1b05997a016585436c5ba185b26306db164b8 100644 (file)
@@ -59,8 +59,27 @@ struct _GtkClipboardClass
 {
   GObjectClass parent_class;
 
-  void (*owner_change) (GtkClipboard        *clipboard,
-                       GdkEventOwnerChange *event);
+  /* vfuncs */
+  gboolean      (* set_contents)                (GtkClipboard                   *clipboard,
+                                                 const GtkTargetEntry           *targets,
+                                                 guint                           n_targets,
+                                                 GtkClipboardGetFunc             get_func,
+                                                 GtkClipboardClearFunc           clear_func,
+                                                 gpointer                        user_data,
+                                                 gboolean                        have_owner);
+  void          (* clear)                       (GtkClipboard                   *clipboard);
+  void          (* request_contents)            (GtkClipboard                   *clipboard,
+                                                 GdkAtom                         target,
+                                                 GtkClipboardReceivedFunc        callback,
+                                                 gpointer                        user_data);
+  void          (* set_can_store)               (GtkClipboard                   *clipboard,
+                                                 const GtkTargetEntry           *targets,
+                                                 gint                            n_targets);
+  void          (* store)                       (GtkClipboard                   *clipboard);
+
+  /* signals */
+  void          (* owner_change)                (GtkClipboard                   *clipboard,
+                                                 GdkEventOwnerChange            *event);
 };
 
 #endif /* __GTK_CLIPBOARD_PRIVATE_H__ */